package com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean;

import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;
import com.example.shushiyunsst.R;
import com.example.wallet.global.AppGlobals;

import java.io.Serializable;

import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.A_LI_PAY;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.BANK_PAY;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.WEI_CHAT_PAY;

public class MyOrderResultBean extends CurrencyOrderInfoBean implements Serializable {


    /**
     * payment : {"pid":2,"uid":2,"isSupportWx":1,"isSupportAipay":1,"isSupportBank":1,"wxUrl":"http://162.247.99.201:81/e990b9986adf483ba388a3dc641a6c4a1602667390957749.jpeg","alipayUrl":"http://162.247.99.201:81/tx/alipay.jpg","bankName":"招商银行","bankNameChild":"北京上地支行","bankNo":"6225880121905099","wxAccount":"123456","createTime":"2020-10-08 14:58:30","realName":"张某某","alipayAccount":"afasdf"}
     * order : {"toid":4,"txid":7,"txNo":"12313123","tokenType":"SST","txType":1,"price":1111,"txNums":2,"totalPrice":2222,"orderStatus":0,"statusDesc":"asdfa","orderDesc":"不要让别人发现","createTime":"2020-09-29 11:22:46","payType":1,"realName":"张未","uidBuyer":1,"uidSeller":2,"isSeller":1}
     */

    @JSONField(name = "payment")
    private PaymentBean payment;

    @JSONField(name = "order")
    private OrderBean order;

    public OrderBean getOrder() {
        return order;
    }

    public int getPayWay() {
        return order.getPayType();
    }

    public String getTotalPrice22() {
        return order.getTotalPrice() + "";
    }

    public String getRealName() {
        return getOrder().getRealName();
    }

    public String getTokenType() {
        return getOrder().getTokenType();
    }

    public void setOrder(OrderBean order) {
        this.order = order;
    }

    public String getAccountName() {
        String str = "";
        switch (order.getPayType()) {
            case WEI_CHAT_PAY:
                str = "微信账号";
                break;
            case A_LI_PAY:
                str = "支付宝账号";
                break;
            case BANK_PAY:
                str = "银行卡号";
                break;
            default:
                str = "";
                break;
        }
        return str;
    }

    public PaymentBean getPayment() {
        return payment;
    }

    public void setPayment(PaymentBean payment) {
        this.payment = payment;
    }

    public String totalPriceUnit() {
        String totalPriceUnit = "金额（CNY)";
        OrderBean order = getOrder();
        if (order == null) return totalPriceUnit;
        String sst = AppGlobals.getApplication().getString(R.string.wallet_sst);

        if (!order.getTokenType().equals(sst)) {
            totalPriceUnit = "金额 (" + sst + ")";
        }
        return totalPriceUnit;
    }

    public String getTxNumUnit() {

        String txNumUnit = "数量（SST)";
        OrderBean order = getOrder();
        if (order == null) return txNumUnit;

        return  "数量（"+order.getTokenType()+")";
    }

    public String priceUnit(){
        String priceUnit = "单价（CNY)";
        OrderBean order = getOrder();
        if (order == null) return priceUnit;
        String sst = AppGlobals.getApplication().getString(R.string.wallet_sst);
        if (!order.getTokenType().equals(sst)) {
            priceUnit = "单价 (" + sst + ")";
        }
        return priceUnit;
    }
}
